Skip to content

Improvements to cyclic checking, avoidance, named parameters #1186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Apr 6, 2016

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 19, 2016

Fixes #1185

@@ -156,16 +156,24 @@ object Checking {
tp
}

def apply(tp: Type) = tp match {
private def apply(tp: Type, cycleOK: Boolean, nestedCycleOK: Boolean): Type = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call these parameters overrideCycleOK or cycleOKOverride to avoid confusion with the class fields

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I picked the same names intentionally. I think there's also value in making clear they are the same.

@odersky
Copy link
Contributor Author

odersky commented Mar 20, 2016

/sync

@odersky
Copy link
Contributor Author

odersky commented Mar 20, 2016

/rebuild

@odersky
Copy link
Contributor Author

odersky commented Mar 20, 2016

This seems to be stuck in the validator. How can this be made unstuck?

@smarter
Copy link
Member

smarter commented Mar 20, 2016

/synch

@smarter
Copy link
Member

smarter commented Mar 20, 2016

@SethTisue : any idea what we can do to unstuck the build?

@smarter
Copy link
Member

smarter commented Mar 20, 2016

@odersky : you could always do git commit --amend --no-edit to change the hash of the last commit and then push -f

@odersky
Copy link
Contributor Author

odersky commented Mar 21, 2016

@smarter OK, that has helped.

@odersky odersky changed the title Improvements to cyclic checking and avoidance Improvements to cyclic checking, avoidance, named parameters Mar 25, 2016
*
* C[type T], D[type U]
*
* Then do you expand `C & D` to `[T, U] -> C[T, U] & D[T, U]` or not? Under the named
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean [T, U] -> C[T] & D[U] ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or actually what we would do for unnamed tparams is [T] -> C[T] & D[T] in such a case.

odersky added 17 commits March 30, 2016 09:51
Simplified logic and now check prefixes of TypeRefs.
Without the simplified logic we would get false cyclic errors for ski.scala.

Test case: flowops.scala

Fixes scala#1185.
The previous formulation broke for named parameters.
Test case in flowops1.scala.
vcInlineMethods could produce a different type on rewire which led to a -Ycheck failure. We now insert
a cast when that happens.

Test case: pos/flowops1.scala with -Ycheck:vcInline.
Type was printed in raw form.
The intent is that Repr implementations should not bind the Out parameter.
Explicitly given type parameters were printed twice.
Add methods for expressing what the named type parameters of a class or type are.
Also, add a method that widens a type so that is has a specified set of named type parameters.
When instantiating a type variable, make the instance has the same named
type parameters as the upper bound. This is the analogue of kind-correctness
for named type parameters.
Do it only if at least one of the types has unnamed parameters. This is
a fundamental conflict with how we deal with intersections and unions.
No need to form the glb.
We should not return a ClassInfo as a value type.
Also: In a TypeMap, the variance of the prefix is unchanged
(was: always 0). This brings it in line with TypeAccumulator
and the subtyping rules.
Now verifies that the named type parameters of an overriding
type or class are the same as the named type parameters of
an overridden type.
@odersky
Copy link
Contributor Author

odersky commented Mar 30, 2016

Rebased to master

@odersky
Copy link
Contributor Author

odersky commented Mar 30, 2016

Ready for review now. This has turned out to be somewhat a grab-bag of features but overall we got some good simplifications in addition to fixing type inference for named parameters.

@odersky odersky merged commit 474d997 into scala:master Apr 6, 2016
override final def namedTypeParams(implicit ctx: Context): Set[TypeSymbol] = {
def computeNamedTypeParams: Set[TypeSymbol] =
if (ctx.erasedTypes || is(Module)) Set() // fast return for modules to avoid scanning package decls
else memberNames(abstractTypeNameFilter).map(name =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we create a NameFilter instance that filters named type params directly instead?

  object namedTypeParamNameFilter extends NameFilter {
    def apply(pre: Type, name: Name)(implicit ctx: Context): Boolean =
      name.isTypeName && {
        val mbr = pre.member(name)
        mbr.symbol.is(Deferred | TypeParam, butNot = ExpandedName) &&
        mbr.info.isInstanceOf[RealTypeBounds]
      }
  }

@allanrenucci allanrenucci deleted the fix-#1185 branch December 14, 2017 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants